{extend name="public:layout" /}
{block name="title"}行业列表{/block}
{block name="head"}
<script type="text/javascript" src="/public/plugins/treetable/jquery.treeTable.js"></script>
{/block}
{block name="body"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li><i class="fa fa-hand-o-right"></i> 行业列表</li>
            </ol>
        </div>
        <div class="ibox-content">
            <div class="toolbar">

                <button class="btn btn-white" type="button"
                        onclick="updateOrder()">
                    <i class="fa fa-sort"></i>更新排序
                </button>
                <a class="btn btn-primary" href="{:url('add')}">
                    <i class="fa fa-plus"></i>&nbsp;添加行业
                </a>
                <a class="btn btn-primary" href="{:url('updateCache')}">
                    <i class="fa"></i>&nbsp;更新缓存
                </a>
            </div>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th width="50">#</th>
                    <th>排序</th>
                    <th>行业名称</th>
                    <th width="150">操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="tradeList" id="vo"}
                <tr id="{$vo.trade_id}" pid="{$vo.trade_pid}">
                    <td>{$vo.trade_id}</td>
                    <td width="80">
                        <input type="text" class="form-control"
                               name="list_order[{$vo.trade_id}]" value="{$vo['trade_sort']}"/>
                    </td>
                    <td>{$vo.trade_name}</td>
                    <td>
                        <a href="{:url('add',['trade_pid'=>$vo['trade_id']])}">添加子行业</a>
                        <a href="{:url('edit',['trade_id'=>$vo['trade_id']])}">编辑</a>
                        <a href="javascript:;" onclick="doAction(this);"
                           data-params="trade_id={$vo.trade_id}"
                           data-url="{:url('del')}"
                           data-msg="确认删除吗？">删除</a>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    $(function () {
        var option = {
            theme: 'vsStyle',
            expandLevel: 2,
            column: 2,
            onSelect: function ($treeTable, id) {
                window.console && console.log('onSelect:' + id);
            }
        };
        $('.table').treeTable(option);
    });
    //更新排序
    function updateOrder() {
        if ($("input[type='text']").length > 0) {
            var data = $("input[type='text']").serialize();
            var url = "{:url('updateOrder')}";
            getAjax(url, data, function (data) {
                top.layer.msg(data.msg, {icon: 1, time: 800}, function () {
                    rePage();
                });
            });
        }
    }
</script>
{/block}